package saas.dev.clouduserprovide.event.common;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : y1
 * @className : PublishEventUtil
 * @date: 2022/7/20 13:54
 * @description :
 */
@Component
public class PublishEventUtil {
    @Resource
    private ApplicationEventPublisher applicationEventPublisher;

    public void sentEvent(ApplicationEvent event) {
        applicationEventPublisher.publishEvent(event);
    }

    public void sentEvent(List<ApplicationEvent> event) {
        event.forEach(item -> applicationEventPublisher.publishEvent(item));
    }
}
